<?php

namespace app\index\controller\kefu;

use think\exception\ValidateException;
use app\model\kefu\Xiansuo;

class XiansuoController extends Base
{

    function index()
    {
        $data['chatid'] = md5(uniqid());
        Xiansuo::updataChat($data);

        $xiansuo =    Xiansuo::where(['chatid' => $data['chatid']])->find()->toArray();

        $res['clientChatEn']['clientChatId'] = $xiansuo['chatid'];
        $res['clientChatEn']['clientChatName'] = $xiansuo['title'];
        $res['clientChatEn']['avatarUrl'] = $xiansuo['fromavatar'];

        $res['serverChatEn']['serverChatId'] = $xiansuo['chatid'];
        $res['serverChatEn']['serverChatName'] = $xiansuo['title'];
        $res['serverChatEn']['avatarUrl'] = $xiansuo['fromavatar'];

        return $this->json(['data' => $res]);
    }
}
